package com.ygp.asyn.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;


@Getter
public enum DownloadReEnum {

    DOWNLOADING(0, "文件下载中"),
    DOWNLOAD_SUC(1, "下载成功"),
    DOWNLOAD_EXC(2, "下载失败"),
    DOWNLOAD_EXPIRE(3, "文件过期"),
    DOWNLOAD_NODATA(4, "无数据"),
    DOWNLOAD_COPY(6, "复制"),

    DOWNLOAD_TOO_MUCH(-2, "下载人数过多"),
    DEFAULT(-1, ""),
    ;

    @Getter
    private final Integer status;
    @Getter
    private final String msg;

    private final static Map<Integer, DownloadReEnum> idMap = new HashMap<>();

    static {
        DownloadReEnum[] values = DownloadReEnum.values();
        for (DownloadReEnum value : values) {
            idMap.put(value.getStatus(), value);
        }
    }

    DownloadReEnum(Integer status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public static String getMsgById(Integer status) {
        return idMap.getOrDefault(status, DEFAULT).getMsg();
    }

}
